package com.example.demo;

import com.example.demo.model.IStockService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import redis.clients.jedis.Jedis;

@SpringBootApplication
@MapperScan("com.example.demo.model")
public class Client1Application implements CommandLineRunner {

	@Autowired
	private IStockService stockService;

	public static void main(String[] args) {
		SpringApplication.run(Client1Application.class, args);
	}

	@Override
	public void run(String... args) throws Exception {
		for (int i = 10; i > 0; i--) {
			// discount stock from mysql
			int finalI = i;
			new Thread(() -> {
				stockService.descCountWithDistribution(finalI);
			}).start();
		}
//		List<Stock> all = stockService.getAll();
//		System.out.println("all======:" + all.get(0));

//		redisTemplate.opsForValue().set("xxx", "sssss");
//		Object xxx = redisTemplate.opsForValue().get("xxx");
//		System.out.println(xxx);
	}
}
